-- wounded_trigger
-- created by panyl
-- 受创触发（诅咒、中毒、净化）

return {
    apply = function(prop, baseValue)
        return prop[3];
    end,

    -- 受创触发
    trigger = function(who, prop, arg)
        local target = arg;
        local value = prop[3];
        -- 燃烧伤害传入的伤害值，需要提前计算好
        local floor = DungeonM.currentLayer();
        local dungeonId = DungeonM.getDungeonId();
        local layerFix = DungeonAreaM.query(dungeonId,"layer_fix");
        local propId = tonumber(prop[2]);

        if propId == PropM.getPropId("burn") then
            value = math.modf(floor * (60 + layerFix) * value / 60 / 1000);
            value = math.max(1, value);
        end

        -- 效果被减弱
        local p = PropM.combine(target, "reduce_negative", propId);
        value = PropM.apply(p, value);
        if value <= 0 then
            return false;
        end

        -- 减益状态，prop的rule必须与状态别名相同
        local round = CombatM.getRound() + prop[4];
        local rule = PropM.query(propId, "rule");
        arr = ({ propId, 1, value, round, });

        local condition = {
            ["prop"] = arr,
            ["end_round"] = round,
        };

        -- 附加状态
        CombatStatusM.applyStatus(target, rule, condition);
    end,

    record = function(target, prop, path)
        return false;
    end
};
